package com.zy.work;

import java.util.*;

/**
 * @Author Gong
 * @Description
 * @dATE 2021/12/13 16:20
 **/
public class Student {
    private String name;
    public Student(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Override
    public boolean equals(Object obj) {
        Student s=(Student)obj;
        return name.equals(s.name);
    }
    @Override
    public int hashCode() {
        String in = name;
        return in.hashCode();
    }
    public static void main(String[] args) {
//        List<Student> stu = new ArrayList<>();
//        stu.add(new Student("001张三"));
//        stu.add(new Student("003李四"));
//        stu.add(new Student("005李四"));
//        stu.add(new Student("112王五"));
//        Set<Student> std = new HashSet<>(stu);
//        for (Student student : std) {
//            System.out.println(student.getName());
//        }

        List list = new ArrayList<>();
        list.add(29);
        list.add(5);
        list.add(29);
        list.add(5);
        list.add(2);
        list.add(2);
        list.add(5);

        List l = removeDuplicate(list);
        for (int i = 0; i < l.size(); i++) {
            System.out.println(l.get(i));
        }
    }

    public static List removeDuplicate(List list) {
        HashSet h = new HashSet(list);
        list.clear();
        list.addAll(h);
        return list;
    }
}
